package com.zhq.blog.core.domain.product;

import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.zhq.blog.core.domain.BaseRepository;

public interface CategoryRepository extends JpaRepository<Category,Long>, BaseRepository<Category>,JpaSpecificationExecutor<Category> {

	@Query("from Category  where flag = 0 and deleted = 0 order by sort asc")
	List<Category> getParent();
	
	@Query("from Category c where c.categoryId = :categoryId and deleted = 0 order by sort asc")
	List<Category> getParent(@Param("categoryId") Long categoryId);
	
	@Query("select b from Category b where deleted=0  order by id desc  ")
	List<Category> findAll();
}
